package com.bjtu.literatureclient.controller.publisher;

import com.bjtu.literatureclient.domain.publisher.CNPublisher;
import com.bjtu.literatureclient.domain.publisher.ENPublisher;
import com.bjtu.literatureclient.service.publisher.ICNPublisherService;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
*@author LMR
*@data 2018年1月31日下午10:05:42
*/
@RestController
@RequestMapping("/publisher")
public class PublisherController {
	
	@Autowired
	ICNPublisherService cnPublisherService;
	
	@SuppressWarnings("unchecked")
	@RequestMapping(method = RequestMethod.POST)
	public String get(HttpServletRequest request){
		String type=request.getParameter("type");
		List<?> cnlist =null;
		if(type.equals("1")){
			cnlist = this.cnPublisherService.query(new ENPublisher(),type);
		}else{
			cnlist = this.cnPublisherService.query(new CNPublisher(),type);
		}
		Gson gson = new Gson();
	    return gson.toJson(cnlist);
	}
	
	
}
